package com.bidevalution.business.impl;

import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.bidevalution.business.dto.BeMethodHeaderDTO;
import com.bidevalution.business.service.BeMethodHeaderService;
import com.bidevalution.dao.entity.BeMethodHeader;
import com.bidevalution.dao.mapper.BeMethodHeaderMapper;
import com.qtp.core.util.IdsUtil;
@Service
public class BeMethodHeaderServiceImpl implements BeMethodHeaderService{
	@Autowired
	private BeMethodHeaderMapper beMethodHeaderMapper;

	@Override
	@Transactional
	public void save(String methodStepId,BeMethodHeaderDTO[] beMethodHeaderDTOList) {
		beMethodHeaderMapper.deleteByMethodStepId(methodStepId);
		BeMethodHeader beMethodHeader;
		int i =1;
		for(BeMethodHeaderDTO beMethodHeaderDTO:beMethodHeaderDTOList) {
			beMethodHeader = new BeMethodHeader();
			beMethodHeader.setClickFunction(beMethodHeaderDTO.getClickFunction());
			beMethodHeader.setControlValue(beMethodHeaderDTO.getControlValue());
			beMethodHeader.setControlType(beMethodHeaderDTO.getControlType());
			beMethodHeader.setControlCode(beMethodHeaderDTO.getControlCode());
			beMethodHeader.setCreateTime(new Date());
			beMethodHeader.setMethodStepId(methodStepId);
			beMethodHeader.setSeqId(IdsUtil.uuid());
			beMethodHeader.setUpdateTime(new Date());
			beMethodHeader.setPermissionConfig(beMethodHeaderDTO.getPermissionConfig());
			beMethodHeader.setOrderNum(i++);
			beMethodHeader.setControlWidth(beMethodHeaderDTO.getControlWidth());
			beMethodHeaderMapper.insert(beMethodHeader);
		}
	}

	@Override
	public List<BeMethodHeader> selectForList(String methodStepId) {
		// TODO Auto-generated method stub
		return beMethodHeaderMapper.selectForList(methodStepId);
	}

	@Override
	public void deleteById(String seqId) {
		beMethodHeaderMapper.deleteByPrimaryKey(seqId);
	}
	

}
